#ifndef _NGX_NGIM_HTTP_MODULE_H_INCLUDED_
#define _NGX_NGIM_HTTP_MODULE_H_INCLUDED_

#include "ngx_ngim.h"
#include "ngx_ngim_http.h"

/* define */
#define PROTO_TAG "GPDH"

/* enum */
enum {
  NGX_NGIM_HTTP_CTX_INIT,
  NGX_NGIM_HTTP_CTX_DO_REQUEST_FINISH,
  NGX_NGIM_HTTP_CTX_PREPARE_RESPONSE_FINISH,
  NGX_NGIM_HTTP_CTX_MAX
};

/* var */
extern ngx_str_t  param_which; 
extern ngx_str_t  param_which_by_idx;
extern ngx_str_t  param_async; 

extern ngx_str_t  json_param_ngim_data; 
extern ngx_str_t  json_param_ngim_cb; 


/* struct */
typedef struct ngx_ngim_http_loc_conf_s {
   ngx_flag_t         http; 
   ngx_uint_t         which;  /* all rnd idx */
   ngx_uint_t         async;  /* sync async async_no */

   ngx_array_t        urls;

} ngx_ngim_http_loc_conf_t;
    

typedef struct ngx_ngim_http_ctx_s {
   ngx_uint_t                 which;  /* all rnd idx */
   ngx_int_t                  which_one;
   ngx_uint_t                 async;  /* sync async async_no */

   ngx_http_request_t        *request;
   ngx_array_t                urls;
   ngx_array_t                request_easyinfo;  /* ngx_ngim_easyinfo_t* */
   ngx_uint_t                 still_running_cnt;

   cJSON                     *http;

   ngx_ngim_session_t        *session;

   unsigned                   stage:4;
} ngx_ngim_http_ctx_t;


/* extern */
extern ngx_module_t  ngx_ngim_http_module;

#endif  //_NGX_NGIM_HTTP_MODULE_H_INCLUDED_
